<template>
  <!-- 头部版心 -->
  <div>
    <div class="wrap header">
      <h1 class="log">
        <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
      </h1>
      <!-- 中间导航 -->
      <ul class="cennav">
        <li :class="$route.path == '/home' ? 'current' : ''" @click="$router.push('/home').catch((err) => {})">首页</li>
        <li :class="$route.path == '/goods' ? 'current' : ''" @click="$router.push('/goods').catch((err) => {})">
          全部商品
        </li>
        <li :class="$route.path == '/user' ? 'current' : ''" @click="$router.push('/user').catch((err) => {})">
          个人中心
        </li>
        <li :class="$route.path == '/order' ? 'current' : ''" @click="$router.push('/order').catch((err) => {})">
          我的订单
        </li>
        <li :class="$route.path == '/free' ? 'current' : ''" @click="$router.push('/free').catch((err) => {})">
          专属福利
        </li>
      </ul>
      <!-- 右边搜索框 -->
      <div class="secach">
        <input type="text" placeholder="请输入关键字" @keyup.13="first" v-model="keyword" />
        <span>
          <img src="../assets/img/search.png" alt="" />
        </span>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      keyword: ''
    }
  },
  methods: {
    first() {
      this.$router.push(`/goods?keyword=${this.keyword}`)
      this.keyword = ''
    }
  }
}
</script>
 
<style lang = "less" scoped>
.header {
  height: 118px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  /*   background: pink; */
  .cennav {
    width: 500px;
    display: flex;
    justify-content: space-between;
    li {
      cursor: pointer;
    }
    .current {
      font-weight: 600;
      color: #f40;
    }
  }
  .secach {
    display: flex;
    input {
      width: 214px;
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      box-sizing: border-box;
      padding-left: 20px;
      outline: none;
    }
    span {
      width: 50px;
      height: 40px;
      line-height: 40px;
      background: #0a328e;
      border-radius: 0px 20px 20px 0px;
      cursor: pointer;
      text-align: center;
      img {
        width: 15px;
        height: 15px;
      }
    }
  }
}
</style>